{% extends './layout.html'%} {%block main%}
<style>
	h6 {
		margin-bottom: 5px;
	}
	
	i.qrcode {
		cursor: pointer;
	}
	
	#qrcode {
		text-align: center;
		padding: 20px 40px;
		display: none;
	}
	
	#qrcode p {
		padding-top: 30px;
	}
	
	#pager {
		text-align: center;
	}
</style>
<blockquote class="layui-elem-quote news_search layui-form">
	<form action="">
		<div class="layui-inline">
			<div class="layui-input-inline">
				<h6>手机号</h6>
				<input type="text" name=phone value="{{phone}}" placeholder="手机号" class="layui-input search_input">
			</div>

		</div>

		<div class="layui-inline">
			<div class="layui-input-inline">
				<h6>开始时间</h6>
				<input type="text" readonly="" name=start_time id=start_time value="{{start_time if start_time != '1970-01-01' else ''}}" placeholder="开始时间" class="layui-input search_input">
			</div>
		</div>

		<div class="layui-inline">
			<div class="layui-input-inline">
				<h6>结束时间</h6>
				<input type="text" readonly="" name=end_time id=end_time value="{{end_time if end_time != '2099-01-01' else ''}}" placeholder="结束时间" class="layui-input search_input">
			</div>
		</div>

		<div class="layui-inline" style=''>
			<h6>&nbsp;</h6>
			<a class="layui-btn layui-btn-normal" onclick='$("form").submit()'>查询</a>

		</div>
	</form>
	<!--<div class="layui-input-inline">
			<input type="text" value="" placeholder="开始时间" class="layui-input search_input">
		</div>
		<div class="layui-input-inline">
			<input type="text" value="" placeholder="结束时间" class="layui-input search_input">
		</div>
		<div class="layui-input-inline">
			<input type="text" value="" placeholder="所属单位" class="layui-input search_input">
		</div>
		<a class="layui-btn search_btn">查询</a>-->
</blockquote>

<div class="layui-form news_list">
	<table class="layui-table">

		<thead>

			<tr>
				<th rowspan="2" width="2%" class="text-center">序号</th>
				<th rowspan="2" width="5%" class="text-center">日期</th>
				<th rowspan="2" width="8%" class="text-center">手机号</th>
				<th rowspan="2" width="10%" class="text-center">客户昵称</th>
				<th rowspan="2" width="20%" class="text-center">所属机构</th>
				<th colspan="2" width="14%" class="text-center">50元</th>
				<th colspan="2" width="14%" class="text-center">100元</th>
				<th rowspan="2" width="7%" class="text-center">总货款</th>
				<th rowspan="2" width="7%" class="text-center">胜率</th>
				<th rowspan="2" width="7%" class="text-center">开奖结果</th>
			</tr>
			<tr>
				<th class="text-center">购货</th>
				<th class="text-center">货款</th>
				<th class="text-center">购货</th>
				<th class="text-center">货款</th>
			</tr>
		</thead>

		<tbody class="news_content">
			{%for item in list%}
			<tr>
				<td>{{loop.index}}</td>
				<td>{{item.add_time | sdate}}</td>
				<td>
					{{item.buyer_phone}}
				</td>
				<td>
					{{item.proxy_member.nickname}}
				</td>
				<td>
					{{item.proxy_member.parent.nickname}}
				</td>

				<td>
					{{item.n50}}
				</td>

				<td>
					{{item.t50}}
				</td>
				<td>
					{{item.n100}}
				</td>

				<td>{{item.t100}}
				</td>	
				<td>
					{{item.total}}
				</td>
				<td>
					{{item.winrate}}%
				</td>

				



				<td>
					{{item.stat}}
				</td>

			</tr>
			{%endfor%}
		</tbody>
	</table>
</div>

<div id='pager'></div>

{%endblock%} {%block js%}
<script src='/static/js/qrcode.js'></script>
<script>
	layui.use(["laydate", "element", "form", "laypage"], function(laydate, ele, form, laypage) {
		//执行一个laydate实例
		laydate.render({
			elem: '#start_time' //指定元素
		});

		laydate.render({
			elem: '#end_time' //指定元素
		});

/**
		laypage.render({
			elem: 'pager',
			count: '{{count}}', //数据总数，从服务端得到
			limit: 20,
			curr: '{{page}}',
			jump: function(obj, first) {
				//obj包含了当前分页的所有参数，比如：
				console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
				console.log(obj.limit); //得到每页显示的条数

				//首次不执行
				if(!first) {
					$('input[name=page]').val(obj.curr);
					$("form").submit();
					//do something
				}
			}
		});
		**/

		$('.show[data-id]').click(function() {
			openWindow("查看", "/proxy/member_detail.html?id=" + $(this).data("id"))
		});

		form.on("select(action)", function(data) {
			var val = data.value;
			if(val == '') {
				return;
			}
			var id = $(data.elem).attr('data-id');
			switch(val) {
				case 'edit':
					openWindow("编辑", "/proxy/addMember.html?id=" + id)
					break;

				case 'login_pass':
					layer.prompt({
						title: '输入新密码',
						formType: 1
					}, function(pass, index) {
						var index = layer.load();
						layer.closeAll();

						$.post("/proxy/api/modify_password", {
							id: id,
							pass: pass,
							"type": "login"
						}, function(msg) {
							if(msg.success) {
								layer.msg("修改成功", {
									icon: 1
								})
							} else {
								layer.msg("修改失败", {
									icon: 2
								})
							}
						}, 'json');
					});
					break;

				case 'pay_pass':
					layer.prompt({
						title: '输入新密码',
						formType: 1
					}, function(pass, index) {
						var index = layer.load();
						layer.closeAll();

						$.post("/proxy/api/modify_password", {
							id: id,
							pass: pass,
							type: "pay"
						}, function(msg) {
							if(msg.success) {
								layer.msg("修改成功", {
									icon: 1
								})
							} else {
								layer.msg("修改失败", {
									icon: 2
								})
							}
						}, 'json');
					});
					break;

				case 'zhuanyi':
					break;
			}
			$(data.othis).parent().find("[lay-value='']").trigger('click');
			//			alert(1)
		});
	});

	function openWindow(title, href) {
		var index = layui.layer.open({
			title: title,
			type: 2,
			content: href,
			success: function(layero, index) {
				setTimeout(function() {
					//layui.layer.tips('点击此处返回', '.layui-layer-setwin .layui-layer-close', {
						//tips: 3
					//});

					var iframe = $('iframe');
					var body = $(iframe.contents()).find("body");
					iframe.height($(window).height() - 100)
				}, 100);
			}
		})

		layui.layer.full(index);
	}

	$(function() {

		$('.qrcode').click(function() {
			var id = $(this).attr('data-id');

			var url = "http://www.baidu.com/s" + id
			$('#qrcode > div').html("").qrcode({
				width: 200,
				height: 200,
				text: url
			});

			$('#qrcode > p').html(url);

			layui.layer.open({
				type: 1,
				content: $('#qrcode'),
				title: "推广二维码"
			});
		});

		$(window).one("resize", function() {
			$('.addJingji').click(function() {
				openWindow("添加", "/proxy/addMember.html?");
			});
		}).resize();
	})
</script>
{%endblock%}